package com.sgb.zhaocai.utils;

import android.content.Context;
import android.util.SparseArray;
import android.widget.ImageView;
import com.blankj.utilcode.util.SizeUtils;
import com.sgb.zhaocai.R;
import com.swgk.core.util.PickSelectTextEntity;
import com.swgk.core.util.ResolutionUtil;

public class PickCopyUtils {


    public static SparseArray<PickSelectTextEntity> deepCopy(SparseArray<PickSelectTextEntity> src) {
        SparseArray<PickSelectTextEntity> dest = new SparseArray<>();
        PickSelectTextEntity newEntity;
        for (int i = 0; i < src.size(); i++) {
            int key = src.keyAt(i);
            PickSelectTextEntity entity = src.get(key);
            newEntity = new PickSelectTextEntity(entity.getSort(), entity.getTypeName(), entity.getPickSelectEntityList());
            dest.put(key, newEntity);
        }
        return dest;
    }

    public static void setImageResources(int i, ImageView imageView, boolean isChoose, Context context) {
        int drawableId = R.drawable.icon_qb;
        switch (i) {
            case 0:
                if (isChoose) {
                    drawableId = R.drawable.icon_qb_xz;
                } else {
                    drawableId = R.drawable.icon_qb;
                }
                break;
            case 1:
                if (isChoose) {
                    drawableId = R.drawable.icon_spcl_xz;
                } else {
                    drawableId = R.drawable.icon_spcl;
                }
                break;
            case 2:
                if (isChoose) {
                    drawableId = R.drawable.icon_zygc_xz;
                } else {
                    drawableId = R.drawable.icon_zygc;
                }
                break;
            case 3:
                if (isChoose) {
                    drawableId = R.drawable.icon_lwfb_xz;
                } else {
                    drawableId = R.drawable.icon_lwfb;
                }
                break;
            case 4:
                if (isChoose) {
                    drawableId = R.drawable.icon_jxzl_xz;
                } else {
                    drawableId = R.drawable.icon_jxzl;
                }
                break;
            case 5:
                if (isChoose) {
                    drawableId = R.drawable.icon_sbzl_xz;
                } else {
                    drawableId = R.drawable.icon_sbzl;
                }
                break;
            case 6:
                if (isChoose) {
                    drawableId = R.drawable.icon_gczb_xz;
                } else {
                    drawableId = R.drawable.icon_gczb;
                }
                break;
            case 7:
                if (isChoose) {
                    drawableId = R.drawable.icon_ppp_xz;
                } else {
                    drawableId = R.drawable.icon_ppp;
                }
                break;
            case 8:
                if (isChoose) {
                    drawableId = R.drawable.icon_tdcqzr_xz;
                } else {
                    drawableId = R.drawable.icon_tdcqzr;
                }
                break;
            case 9:
                if (isChoose) {
                    drawableId = R.drawable.icon_fczr_xz;
                } else {
                    drawableId = R.drawable.icon_fczr;
                }
                break;
            case 10:
                if (isChoose) {
                    drawableId = R.drawable.icon_sjgh_xz;
                } else {
                    drawableId = R.drawable.icon_sjgh;
                }
                break;
            case 11:
                if (isChoose) {
                    drawableId = R.drawable.icon_zyjl_xz;
                } else {
                    drawableId = R.drawable.icon_zyjl;
                }
                break;
            case 12:
                if (isChoose) {
                    drawableId = R.drawable.icon_dzkc_xz;
                } else {
                    drawableId = R.drawable.icon_dzkc;
                }
                break;
            case 13:
                if (isChoose) {
                    drawableId = R.drawable.icon_zjzx_xz;
                } else {
                    drawableId = R.drawable.icon_zjzx;
                }
                break;
            case 14:
                if (isChoose) {
                    drawableId = R.drawable.icon_fczl_xz;
                } else {
                    drawableId = R.drawable.icon_fczl;
                }
                break;
            case 15:
                if (isChoose) {
                    drawableId = R.drawable.icon_clzl_xz;
                } else {
                    drawableId = R.drawable.icon_clzl;
                }
                break;
            case 16:
                if (isChoose) {
                    drawableId = R.drawable.icon_jxzr_xz;
                } else {
                    drawableId = R.drawable.icon_jxzr;
                }
                break;
            case 17:
                if (isChoose) {
                    drawableId = R.drawable.icon_sbzr_xz;
                } else {
                    drawableId = R.drawable.icon_sbzr;
                }
                break;
            case 18:
                if (isChoose) {
                    drawableId = R.drawable.icon_clzr_xz;
                } else {
                    drawableId = R.drawable.icon_clzr;
                }
                break;
            case 19:
                if (isChoose) {
                    drawableId = R.drawable.icon_wlhy_xz;
                } else {
                    drawableId = R.drawable.icon_wlhy;
                }
                break;
            case 20:
                if (isChoose) {
                    drawableId = R.drawable.icon_qt_xz;
                } else {
                    drawableId = R.drawable.icon_qt;
                }
                break;
            default:
                break;
        }
        imageView.setBackgroundResource(drawableId);
        imageView.setScaleX(0);
        imageView.setScaleY(0);
        float scale;
        if(isChoose){
            scale =  SizeUtils.dp2px(45) /  (float)SizeUtils.dp2px(36);
        } else {
            scale =  SizeUtils.dp2px(36) /  (float)SizeUtils.dp2px(36);
        }
        imageView.setScaleX(scale);
        imageView.setScaleY(scale);
    }

    public static void setDemandForecastIv(int i, ImageView imageView, boolean isChoose, Context context) {
        int drawableId = R.mipmap.zc_clcg;
        switch (i) {
            case 0:
                if (isChoose) {
                    drawableId = R.mipmap.zc_clcg_xz;
                } else {
                    drawableId = R.mipmap.zc_clcg;
                }
                break;
            case 1:
                if (isChoose) {
                    drawableId = R.mipmap.zc_jxzl_xz;
                } else {
                    drawableId = R.mipmap.zc_jxzl;
                }
                break;
            case 2:
                if (isChoose) {
                    drawableId = R.mipmap.zc_sbzl_xz;
                } else {
                    drawableId = R.mipmap.zc_sbzl;
                }
                break;
            case 3:
                if (isChoose) {
                    drawableId = R.mipmap.zc_lwfg_xz;
                } else {
                    drawableId = R.mipmap.zc_lwfg;
                }
                break;
            case 4:
                if (isChoose) {
                    drawableId = R.mipmap.zc_fbjh_xz;
                } else {
                    drawableId = R.mipmap.zc_fbjh;
                }
                break;
            default:
                break;
        }
        imageView.setBackgroundResource(drawableId);
        imageView.setScaleX(0);
        imageView.setScaleY(0);
        float scale;
        if(isChoose){
            scale =  SizeUtils.dp2px(45) /  (float)SizeUtils.dp2px(36);
        } else {
            scale =  SizeUtils.dp2px(36) /  (float)SizeUtils.dp2px(36);
        }
        imageView.setScaleX(scale);
        imageView.setScaleY(scale);
    }

    public static void setDemandForecastModel(int i, ImageView imageView, boolean isChoose, Context context) {
        int drawableId = R.mipmap.zc_clcg;
        switch (i) {
            case 0:
                if (isChoose) {
                    drawableId = R.mipmap.zc_gcxm_xz;
                } else {
                    drawableId = R.mipmap.zc_gcxm;
                }
                break;
            case 1:
                if (isChoose) {
                    drawableId = R.mipmap.zc_clcg_xz;
                } else {
                    drawableId = R.mipmap.zc_clcg;
                }
                break;
            case 2:
                if (isChoose) {
                    drawableId = R.mipmap.zc_jxzl_xz;
                } else {
                    drawableId = R.mipmap.zc_jxzl;
                }
                break;
            case 3:
                if (isChoose) {
                    drawableId = R.mipmap.zc_sbzl_xz;
                } else {
                    drawableId = R.mipmap.zc_sbzl;
                }
                break;
            case 4:
                if (isChoose) {
                    drawableId = R.mipmap.zc_lwfg_xz;
                } else {
                    drawableId = R.mipmap.zc_lwfg;
                }
                break;
            case 5:
                if (isChoose) {
                    drawableId = R.mipmap.zc_fbjh_xz;
                } else {
                    drawableId = R.mipmap.zc_fbjh;
                }
                break;
            default:
                break;
        }
        imageView.setBackgroundResource(drawableId);
        imageView.setScaleX(0);
        imageView.setScaleY(0);
        float scale;
        if(isChoose){
            scale =  ResolutionUtil.dp2px(context, 45) /  (float)ResolutionUtil.dp2px(context, 36);
        } else {
            scale =  ResolutionUtil.dp2px(context, 36) /  (float)ResolutionUtil.dp2px(context, 36);
        }
        imageView.setScaleX(scale);
        imageView.setScaleY(scale);
    }
}
